/**
 * Copyright (C) 2014 Jonas Lammers
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 *
 */
package mygame;

import java.util.ArrayList;

/**
 *
 * @author jonas
 */
public class CollisionObjectList {
    
    private ArrayList listX;
    private ArrayList listY;
    private ArrayList listZ;
    
    public CollisionObjectList(){
        
    }    
    
    //insertion sort
    private void sort(ArrayList<CollisionObject> list, int axis){
        for (int i=1; i < list.size(); i++){
            CollisionObject temp = list.get(i);
            int j = i - 1;
            
            if(axis==0)            
            while (j >= 0 && list.get(j).getPosition().getX() > temp.getPosition().getX()){
                list.set(j + 1, list.get(j));
                j--;
            }
            else if(axis==1)
            while (j >= 0 && list.get(j).getPosition().getY() > temp.getPosition().getY()){
                list.set(j + 1, list.get(j));
                j--;
            }
            else
            while (j >= 0 && list.get(j).getPosition().getZ() > temp.getPosition().getZ()){
                list.set(j + 1, list.get(j));
                j--;
            }    

            list.set(j+1, temp);
        }
    }
}
